package com.self.test.gaobingfa;

/**
 * 在执行同步方法的时候可以同时执行普通方法
 * **/
public class SynchronizedTest1 {

	public synchronized void void1() {
		System.out.println(Thread.currentThread().getName() + " void1 thread start");
		try {
			Thread.sleep(10000);
		} catch (InterruptedException e) {
			e.printStackTrace();
		}
		System.out.println(Thread.currentThread().getName() + " void1 thread end");
	}
	
	public void void2() {
		try {
			Thread.sleep(5000);
		} catch (InterruptedException e) {
			e.printStackTrace();
		}
		System.out.println(Thread.currentThread().getName() + " void2 end");
	}
	
	public static void main(String[] args) {
		final SynchronizedTest1 t = new SynchronizedTest1();
		
		new Thread(new Runnable() {
			@Override
			public void run() {
				t.void1();
			}
		}).start();
		new Thread(new Runnable() {
			@Override
			public void run() {
				t.void2();
			}
		}).start();
		
	}


}
